package com.zengdb.mybatis.page;

import java.util.List;

import lombok.Getter;
import lombok.Setter;

/**
 * 分页查询结果对象
 * @author zengdb
 *
 */
@Getter@Setter
public class PageResult<T> {
	
	private Integer total; //总记录数
	private List<T> data; //当前页的数据集合
	private Integer currentPage; //当前页第几页
	private Integer pageSize; //每页显示条数
	private Integer prevPage; //上一页第几页
	private Integer nextPage; //下一页第几页
	private Integer totalPage; //总页
	
	public PageResult(Integer total, List<T> data, Integer currentPage, Integer pageSize) {
		super();
		this.total = total;
		this.data = data;
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.totalPage = total % pageSize == 0 ? (total / pageSize) : (total / pageSize + 1);
		this.prevPage = currentPage - 1 > 1 ? (currentPage - 1) : 1;
		this.nextPage = currentPage + 1 < totalPage ? (currentPage + 1) : totalPage;
	}
	
}
